from django.contrib import admin
from models import *

from django.contrib.contenttypes.models import *

class MessageAdmin(admin.ModelAdmin):
    list_display = ['communication','date','sent','instance_object','to']


def send_all(modeladmin, request, queryset):
    for p in queryset.all():
        p.send_all()


class CommunicationAdmin(admin.ModelAdmin):
    list_display = ['name','subject','email','model','queryset','condition','resend_every','max_times','auto']
    actions = [send_all]

admin.site.register(Communication, CommunicationAdmin)
admin.site.register(Account)
admin.site.register(Message, MessageAdmin)
admin.site.register(Suscription)

if not ContentType in admin.site._registry:
    admin.site.register(ContentType)
